package com.woniuxy.personal.core.controller;


import com.woniuxy.common.CommonResult;
import com.woniuxy.personal.core.model.PlOrderitem;
import com.woniuxy.personal.core.service.PlOrderService;
import com.woniuxy.personal.core.service.PlOrderitemService;
import com.woniuxy.personal.core.vo.FinanceVo;
import com.woniuxy.personal.core.vo.PlOrderitemDto;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.xml.crypto.Data;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author gmx
 * @since 2021-06-29
 */
@RestController
@RequestMapping("/orderitem")
public class PlOrderitemController {

    @Resource
    private PlOrderitemService service;

    @Resource
    private PlOrderService orderService;

    @GetMapping("selectMoney/{storeId}")

    public CommonResult selecMoney(@PathVariable("storeId") int storeId){
        List<FinanceVo> financeVos = new ArrayList<>();

        List<String> list = this.service.selectName(storeId);
        for (String s : list) {
            FinanceVo financeVo = new FinanceVo();
            financeVo.setName(s);
            financeVo.setStack("总量");
            financeVo.setType("line");
            List<Double> price = this.service.seletByName(s);
            financeVo.setData(price);
            financeVos.add(financeVo);
        }
        return CommonResult.success(financeVos);
    }


    @GetMapping("selectTime/{storeId}")
    public CommonResult selectTime(@PathVariable("storeId") int storeId){
        List<Integer> list = this.service.seletOrderId(storeId);
        List<Date> list1 = new ArrayList<>();
        for (Integer i :list) {
            Date time = this.orderService.selectTimeByOrderId(i);
            list1.add(time);
        }
        return CommonResult.success(list1);
    }

}

